<template>
  <div class="home">
    <swiper/>
    <div class="section" v-for="(item,index) in songsList" :key="index">
      <div class="section-title">{{item.name}}</div>
      <content-list :contentList = "item.list"></content-list>
    </div>
  </div>
</template>

<script>
import Swiper from "../components/Swiper.vue"
import contentList from "../components/ContentList.vue";
import {getAllSinger,getAllSongList} from  "../api/index"
export default {
  name: 'home',
  components: {
    Swiper,
    contentList
  },
  data () {
    return {
      songsList: [
        {name: '歌单',list:[]},
        {name: '歌手',list:[]}
      ]
    }
  },
  created () {
    this.getSinger();
    this.getSongList();
  },
  methods: {
    // 获取前10条歌单
      getSongList(){
        getAllSongList().then((res) => {
          this.songsList[0].list = res.slice(0,10);
        }).catch((err) =>{
          console.log(err);
        })
      },
      // 获取前10条歌手信息
      getSinger(){
        getAllSinger().then((res) => {
          this.songsList[1].list = res.slice(0,10);
        }).catch((err) =>{
          console.log(err);
        })
      }
  }
}
</script>

<style lang="scss" scoped>
@import '../assets/css/home.scss';
</style>
